<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="开始时间" prop="dataStartTime">
        <el-date-picker
          v-model="queryParams.dataStartTime"
          type="date"
          placeholder="请选择开始时间"
          clearable
          :editable="false"
          value-format="yyyy-MM-dd"
          @keyup.enter.native="handleQuery"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="dataEndTime">
        <el-date-picker
          v-model="queryParams.dataEndTime"
          type="date"
          placeholder="请选择结束时间"
          clearable
          :editable="false"
          value-format="yyyy-MM-dd"
          @keyup.enter.native="handleQuery"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <div class="num-info">
      <div class="num-info-item">
        <div>粉丝订单数</div>
        <div class="info-item-name">{{ countData.orderNumber || 0 }}</div>
      </div>
      <div class="num-info-item">
        <div>粉丝订单金额</div>
        <div class="info-item-name">{{ countData.orderMoney || 0 }}</div>
      </div>
      <!-- <div class="num-info-item">
        <div>粉丝订单业绩</div>
        <div class="info-item-name">没有字段</div>
      </div> -->
    </div>

    <el-table :data="ruleList" highlight-current-row>
      <el-table-column label="会员ID" align="center" prop="userId" width="80" />
      <el-table-column label="会员" prop="userName" width="180">
        <template slot-scope="scope">
          <div class="user-box">
            <el-image
              style="width: 50px; height: 50px; margin-right: 5px"
              :src="scope.row.avatar"
            ></el-image>
            <div>
              <div>{{ scope.row.nickName }}</div>
              <div>{{ scope.row.phonenumber }}</div>
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="订单号" align="center" prop="orderId" />
      <el-table-column label="支付金额" align="center" prop="payMoney" />
      <el-table-column label="运费" align="center" prop="deliveryCost" />
      <!-- <el-table-column label="业绩" align="center" prop="kpi">
        <template> 没字段 </template>
      </el-table-column> -->
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <!-- <el-table-column label="下单时间" align="center" prop="orderTime"
        >没字段</el-table-column
      > -->
    </el-table>

    <!-- total -->
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {
  getTeamPerformance,
  getTeamPerformanceStatistics,
} from "@/api/data/team";
export default {
  name: "Kpi",
  props: ["id"],
  data() {
    return {
      // 查询参数
      queryParams: {
        pageSize: 10,
        pageNum: 1,
        userId: this.$route.query.id,
        dataStartTime: null,
        dataEndTime: null,
      },
      total: 0,
      ruleList: [],
      countData: {},
    };
  },
  created() {
    this.getList();
  },
  mounted() {},
  methods: {
    // 查询团队业绩列表
    getList() {
      this.getCountTeam();
      this.loading = true;
      getTeamPerformance(this.queryParams).then((response) => {
        this.ruleList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /**查询团队业绩统计 */
    getCountTeam() {
      getTeamPerformanceStatistics(this.queryParams).then((res) => {
        this.countData = res.data;
      });
    },
    // 搜索按钮
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置按钮
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>

<style lang="less" scoped>
.num-info {
  display: flex;
  padding: 20px 0;

  .num-info-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-content: center;

    div {
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 13px;
      color: #606266;
    }

    .info-item-name {
      margin: 6px 0 0;
      font-size: 20px;
      color: #303133;
    }
  }
}

.user-box {
  display: flex;
  justify-content: center;
}
</style>
